<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/struts/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="./style/alternative.css" media="all" rel="stylesheet" />
<style type="text/css">
#itemAction {
padding-left: 0.3em;
word-spacing:normal;
text-align:left;
}
#itemAction input {
background-color:#389;
color:#eec;
font-family: Arial;
}
#taskAction {
padding-left: 0.5em;
text-align:right;
}
</style>
<script type='text/javascript' src='script/prototype.js'></script>
<script type='text/javascript' src='script/common.js'></script>

<SCRIPT LANGUAGE="JavaScript">
var checkedAll = false;

function onDelete(){
     var s = $$('#table input');
     var trs = $$('#table tr');
     for(var i=s.length-1; i>=0; i--)
     {
      if (s[i].checked)
       trs[i].remove();
     }

}
function checkForm(){
    var checked = "";
    $$('input[type="checkbox"][name="itemID"]').select(function(i){return i.checked}).each(function(i)
    {
       //alert(i.value)
       checked = checked + i.value;
    });  
    if(checked=="") {
        alert("请选择一个事务");
        return false;
    }
    return true;
    
} 


function submitForm(imethod, itype) {
    var ret = true;
    //alert("imethod=" + imethod);
    if(imethod!="add") {
        ret = checkForm()
    } 
    if(imethod == 'delete') {
        var ret = confirm("你确信删除这些记录吗?");
        if(!ret) {
            return;
        }
    } else if(imethod == 'asTask') {
        $("taskType").value = itype;
        alert("taskType=" + $F("taskType"));
    } else if(imethod == 'asItem') {
        $("itemType").value = itype;
        alert("itemType=" + $F("itemType"));
    }
    if(ret) {
        $("method").value=imethod;
        $("itemsForm").submit();
    }
}
</SCRIPT>
</head>
<body>
<div id="content"><div id="content_inner">
<center>
<h2>
<c:choose>
<c:when test="${param.itemType==3}">
健康清单
</c:when>
<c:when test="${param.itemType==4}">
生日清单
</c:when>
<c:when test="${param.itemType==5}">
维修清单
</c:when>
<c:when test="${param.itemType==6}">
假日清单
</c:when>
<c:when test="${param.itemType==7}">
清洁清单
</c:when>
<c:when test="${param.itemType==8}">
幸福感清单
</c:when>
<c:otherwise>
生活清单
</c:otherwise>
</c:choose>
</h2>
</center>

<form name="itemsForm" id="itemsForm" method="post" action="life.htm">
<display:table htmlId="itemList" name="itemList" sort="list" 
     class="its" id="item" requestURI="life.htm">
<display:setProperty name="basic.empty.showtable" value="true" />
<display:setProperty name="basic.msg.empty_list_row" value="<tr class='empty'><td colspan='{0}'>没有记录</td></tr>"/>

<display:column title="事务" sortable="true" headerClass="sortable">
<img src="images/bullet.gif"/>&nbsp;
<INPUT TYPE="hidden" NAME="itemID" ID="itemID" value="${item.itemID}" >
<a href="life.htm?method=edit&itemID=${item.itemID}&itemType=${item.itemType}">${item.itemName}</a>
</display:column>
<display:column property="description" title="细节" sortable="true" headerClass="sortable"/>
<display:column title="类别" sortable="true" headerClass="sortable">
<c:choose>
<c:when test="${item.itemType==3}">
健康清单
</c:when>
<c:when test="${item.itemType==4}">
生日清单
</c:when>
<c:when test="${item.itemType==5}">
维修清单
</c:when>
<c:when test="${item.itemType==6}">
假日清单
</c:when>
<c:when test="${item.itemType==7}">
清洁清单
</c:when>
<c:when test="${item.itemType==8}">
幸福感清单
</c:when>
<c:otherwise>
生活清单
</c:otherwise>
</c:choose>
</display:column>
<display:column title="创建时间" sortable="true" headerClass="sortable" style="width:6em">
<fmt:formatDate value="${item.createTime}" pattern="MM/dd/yy HH:mm:ss"/>
</display:column>
<display:column title="<img src='images/add.png' onclick=\"submitForm('add')\" value='添加'/>" headerClass="taskOperation" style="white-space:nowrap">
<a href="life.htm?method=edit&itemID=${item.itemID}&itemType=${param.itemType}" class="icon_btn pic_edit" title="Edit Task"><span>Edit Item</span></a>
<a href="life.htm?method=delete&itemID=${item.itemID}&itemType=${param.itemType}" class="icon_btn pic_delete" title="Delete Task"><span>Delete Item</span></a>
</display:column>
</display:table>
<div id="itemAction">
<input type="hidden" name="method" id="method">
<input type="hidden" name="itemType" id="itemType" value="${param.itemType}">
</div>
</form>
</div><!-- content_inner -->
</div><!-- content -->
</body>
</html>